<?python
    from turbogears import identity
    from mnemoply.model import constants
?>
<span xmlns:py="http://genshi.edgewall.org/">
    <table>
        <thead>
        <tr>
            <th>#</th>
            <th>Topic</th>
            <th>Hours</th>
            <th>Actions</th>
        </tr>
        </thead>

        <tbody>
        <tr py:for="topic in obj.topics">
            <td>${topic.ordinal}</td>
            <td><a href="/Topic/${topic.topic.id}/">${topic.topic.title}</a></td>
            <td>${topic.hours}</td>
            <td>
                <span py:if="identity.has_any_permission('dba', 'PlanTopic/edit')">
                    <a href="edit_topic_req?tid=${topic.id}">edit</a>
                    <a href="delete_topic?tid=${topic.id}">delete</a>
                    <a href="up_topic?tid=${topic.id}"><b>&#8593;&#8593;&#8593;</b></a>
                    <a href="down_topic?tid=${topic.id}"><b>&#8595;&#8595;&#8595;</b></a>
                </span>
            </td>
        </tr>
        <tr>
            <td />
            <td />
            <td>
                <?python
                    from decimal import Decimal
                    total_hours = Decimal(0)
                    for topic in obj.topics:
                        total_hours += topic.hours
                ?>
                ${total_hours}
            </td>
            <td />
        </tr>
        </tbody>
    </table>

    <hr />

    <span py:if="identity.has_any_permission('dba', 'PlanTopic/edit')">${ET(tab.add_form())}</span>
</span>

